<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/WEB-INF/base.jspf"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户提款管理</title>
<style>
 #date1 {
	 margin: 2px;  
	 height: 37px;
}

#date2 {
	margin: 2px;
	height: 37px;
}
	.modal-dialog {
		max-width: 1000px;
	}
.select-lx {
	margin: 2px;
	height: 37px;
}

#zflx {
	margin: 2px;
	height: 37px;
}

.layui-inline {
	height: 100px;
	margin-top:15px;
}

#hymc {
	width: 199px;
	height: 37px;
}
#daili{
  width:199px;
  height:37px;
}
.copy-btn {
	cursor: pointer;
}
.hidden-c {
	display:none;
}
#table_id_example_paginate{
 margin-right:100px;
}
.class-input-pageNumber{
    
	width:40px;
	height:23px;
	position: absolute;
	right:550px;
	top:12px;
}
.class-span-searchBtn{
	height:24px;
	width:36px;
	font-size:14px;
	text-algin:center;
	line-height:25px;
	padding:0!important;
	position: absolute;
	right:500px;
	top:12px;
}
.dataTables_length{
	margin-top:12px;
	margin-left:50px;
}
.tableSearch{
    position: relative;
}
.hidden-c {
	display:none;
}

.btn-c-dealShenQing {
	display:none;
}
table th,table tr,table td {
text-align: center;
vertical-align:middle;
}
.input-auto{
text-align: center;
vertical-align:middle;
}
.layui-btn{

}
</style>
</head>
			<div class="layui-inline">
				<div class="layui-inline">
					<input type="text" id="date1" placeholder="开始时间" value="">
					<input type="text" id="hymc"  placeholder="会员名称" value=""> <br>
					<input type="text" id="date2" placeholder="结束时间" value="">
					<input type="text" id="daili"  placeholder="所属代理" value="">
				</div>
				<div class="layui-inline">
					<select id="tklx" class="select-lx">
						<option value="">提款类型</option>
						<option value="在线提款"> &nbsp;&nbsp;在线提款</option>
						<option value="人工扣款"> &nbsp;&nbsp;人工扣款</option>
					</select>  
					<button class="layui-btn layui-btn-radius" id="btn_search" style="margin-left:25px;">查询</button><br>
					<select id="czzt" class="select-lx">
						<option value="">提款状态</option>
						<option value="未处理">&nbsp;&nbsp;未处理</option>
						<option value="处理中">&nbsp;&nbsp;处理中</option>
						<option value="提款成功">&nbsp;&nbsp;提款成功</option>
						<option value="提款失败">&nbsp;&nbsp;提款失败</option>
					</select>
					<button class="layui-btn layui-btn-radius" id="button-i-resetTableContent" style="margin-left:25px;">重置</button>
				</div>
			</div>
			<div>
				<table class="class-tableDataTable class-table-needClick display table table-striped table-bordered table-hover" id="khtkjl">
					<thead>
						<tr>
							<th class="hidden-c"></th>
							<th class="hidden-c"></th>
							<th class="hidden-c"></th>
							<th>用户账号</th>
							<th>提款操作</th>
							<th>提款户名</th>
							<th>提款账号</th>
							<th>提款金额</th>
							<th>提款银行</th>
							<th>申请时间</th>
							<th>处理时间</th>
							<th>提款类型</th>							
							<th>提款状态</th>
							<th>操作人员</th>
							<th>操作备注</th>
						</tr>
						
					</thead>
				</table> 
				<div id="copy-temp"></div>
			</div>
<!-- 提醒模态框（Modal） -->

<div class="modal fade" id="noticeModal" tabindex="-1" role="dialog" aria-labelledby="noticeModal" aria-hidden="true">
    <div class="modal-dialog class-fake-alert">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body" ></div>
            <div class="modal-footer">	      
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>   	

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="max-width:900px;width:900px;min-width:900px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">处理申请</h4>
            </div>
            <div class="modal-body">
			<table class="table table-bordered table-striped">
				<tbody>
					<tr>
						<td width="17%" class="text-right">会员账号：</td>
						<td width="30%" class="input-auto" id="input-i-accout"></td>
						<td width="23%" class="text-right">提款类型：</td>
						<td width="30%" class="input-auto" id="input-i-tikuanleixing"></td>
					</tr>
					<tr>
						<td class="text-right">提款银行：</td>
						<td class="input-auto" id="input-i-bankType"></td>
						<td class="text-right">提款户名：</td>
						<td class="input-auto" id="input-i-shoukuanhuming">
						</td>
					</tr>
					<tr>
						<td class="text-right">提款帐号：</td>
						<td class="input-auto" id="input-i-bankaccount">
						</td>
						<td class="text-right">提款手续费：</td>
						<td id="input-i-shouxufei">
						</td>
						
					</tr>
					<tr>
						<td class="text-right">申请时间：</td>
						<td class="input-auto" id="input-i-qukuanTime"></td>
						<td class="text-right">提款所需打码量：</td>
						<td id="ajax-i-tikuansx"></td>
						
					</tr>
					<tr>
						<td class="text-right">有效投注额：</td>
						<td id="ajax-i-damaliang"></td>
						<td class="text-right media-middle">是否可以提款：</td>
						<td class="media-middle">
							<span class="text-success">是</span>
						</td>
					</tr>
					<tr>
						<td class="text-right media-middle">提款金额：</td>
						<td><h4 class="text-danger input-auto" id="input-i-shenqingjine"></h4>
						</td>
						<td class="text-right media-middle">提款总额(次数)：</td>
						<td class="media-middle" id="qikuanzonge-i"></td>
						
					</tr>
					<tr>
						<td class="text-right media-middle">充值总额(次数)：</td>
						<td class="media-middle"  id="chongzhizonge-i"></td>
						<td class="text-right media-middle">处理结果：</td>
						<td><select name="status" id="select-i-dealState" class="form-control">
							<option value="提款成功" >提款成功</option>
							<option value="信息有误">信息有误</option>
						</select></td>
					</tr>
					<tr>
						<td class="text-right media-middle ">会员备注信息：</td>
						<td id="input-i-beizhu" class="input-auto"></td>
					</tr>
					<tr class="hidden eremark">
						<td class="text-right" >失败原因：</td>
						<td colspan="3"><input type="text" name="remark" class="form-control"></td>
					</tr>
				</tbody>
			</table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="btn-i-dealNewTiKuan">提交更改</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>			
			
	<script>
	var $_PARENT_TR
		 layui.use('laydate', function() {
			var laydate = layui.laydate;
			//执行一个laydate实例
			laydate.render({
				elem : '#date1' //指定元素
			});
		});
		layui.use('laydate', function() {
			var laydate = layui.laydate;
			//执行一个laydate实例
			laydate.render({
				elem : '#date2' //指定元素
			});
		});
		function dataTable01(){
			var oTable=	$("#khtkjl").DataTable({
					 "bProcessing" : false, // 是否显示取数据时的那个等待提示
					"bServerSide" : true,//这个用来指明是通过服务端来取数据
					 "bPaginate" : true, //是否显示分页 
					"sAjaxSource" : "/zhgl/findUserDrawingRecord.do",//这个是请求的地址
					"fnServerData" : retrieveData, // 获取数据的处理函数
					"destroy":true,
				      // "bPaginate": true,
				       "bLengthChange": true,      
				      "bSort": false,
				      // "bInfo": true,
				      "bAutoWidth": false,
//				         "bServerSide":true,
				      'aLengthMenu':[5,10, 20], 
				       "searching": false,  
				        "pagingType": "simple_numbers",
				       "dom": "t<'tableinfo'i<'tableSearch'p>l>", 
				       
				       "language": {//语言设置  
				            "lengthMenu": "每页显示 _MENU_ 条记录",     
				            "zeroRecords": "没有检索到数据",     
				            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
				            "info": "没有数据",     
				            "oPaginate": {     
				                "sFirst": "首页",     
				                "sPrevious": "前一页",     
				                "sNext": "后一页",     
				                "sLast": "尾页"    
				          	},
				            "search":"",
				            "searchPlaceholder": "请输入关键字",
				            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
				            "infoEmpty":      "没有找到匹配的信息",
				         },  
				         "columnDefs": [{"defaultContent": "",
                             "targets": "_all"}],
				         "columns": [
				        	 {"data": "id", "className": "hidden-c id-td"},
 		                     {"data": "userid", "className": "hidden-c user-td"},
 		                    {"data": "tikuansxf", "className": "hidden-c tikuansxf-td"},
		                     { "data": "name",  "className" : "accout-td" },
		                     { "data": "caozuo" },
		                     { "data": "skname", "className" : "shoukuanhuming-td"},
		                     { "data": "skbankzh", "className" : "bankaccount-td" },
		                     { "data": "tikuanje", "className": "shenqingjine-td" },
		                     { "data": "zhifupt", "className" : "bankType-td"},
		                     { "data": "sqtime", "className" : "qukuanTime-td" },
		                     { "data": "cltime" },
		                     { "data": "type",   "className" : "tikuanleixing-td" },
		                     { "data": "state" },
		                     { "data": "czname" },
		                     { "data": "beizhu", "className": "beizhu-td" },
		                 ],	
				})
		/* var cname
		if($(".nav-tabs-fake li")) */
			
				

	function retrieveData(sSource, aoData, fnCallback) {
				$.ajax({
					url : sSource,//这个就是请求地址对应sAjaxSource
					data : {
						"pageCount":aoData[0].value,
						"startIndex":aoData[3].value,
						"lineCount":aoData[4].value,
						/*  "date1" : $('#date1').val(),
		    	        "date2" : $('#date2').val(),
		    	        "hydengji": $('#zflx').val(),
		    	        "type" :$('#czlx').val(),
		    	        "state" : $('#czzt').val(),
		    	        "name" :$('#hymc').val(),
		    	        "daili" : $('#daili').val(), */
					},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
					type : 'post',
					dataType : 'json',
					async : false,
					 
					success : function(result) { 
						var newJson = result.aaData
		        		 for (var i = 0; i < newJson.length; i++) {
		         			 var item = newJson[i]
		         			 if (item.caozuo == "锁定") {
		         				 var caozuoHTML = "<button data-type='unlock' class='btn-c-suoding btn btn-primary'>锁定</button>"
		         			 	 var dealShenQingBtn = "<button class='btn-c-dealShenQing btn btn-success'>处理申请</button>"
		         			 	 item.caozuo = caozuoHTML + dealShenQingBtn
		         			 } else if (item.caozuo == "取消锁定") {
		         				var caozuoHTML = "<button data-type='lock' class='btn-c-suoding btn btn-primary'>取消锁定</button>"
		         			 	 var dealShenQingBtn = "<button class='btn-c-dealShenQing btn btn-success active'>处理申请</button>"
		         			 	 item.caozuo = caozuoHTML + dealShenQingBtn			         				 
		         			 }
		        		 }
						result.aaData = newJson;
						fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
						 $("tbody tr td.shoukuanhuming-td").append("<button class='tikuan-name form-control btn-default'>复制</button>") 
						 $("tbody tr td.bankaccount-td").append("<button class='tikuan-name form-control btn-default'>复制</button>")
						 $("tbody tr td.shenqingjine-td").append("<button class='tikuan-name form-control btn-default'>复制</button>")
						 $("tbody tr td.bankType-td").append("<button class='tikuan-name form-control btn-default'>复制</button>")
						
					},
					error : function(msg) {
					}
				});
			}
		}
		
		
		 function copyContent(){ 
	    	   var clipboard = new ClipboardJS('#copy_btn');      
		       clipboard.on('success', function(e) {      
		           e.clearSelection();      
		       })
		       $("#copy_btn").on(getEndClickEvent(), function() {
		    	   showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "复制成功！")
		       })
 		 };
		
		dataTable01()
		insertSearchBtn()
		document.querySelector("#btn_search").addEventListener("click", function(event) {
			if($("#date1").val()=="" && $("#date2").val()=="" &&  $("#tklx").val()==""
				&& $("#czzt").val()=="" && $("#hymc").val()=="" && $("#daili").val()==""){
				 return 
			 }	
			else{
				var oTable=	$("#khtkjl").DataTable({
					 "bProcessing" : false, // 是否显示取数据时的那个等待提示
					"bServerSide" : true,//这个用来指明是通过服务端来取数据
					 "bPaginate" : true, //是否显示分页 
					"sAjaxSource" : "/zhgl/likeFindUserDrawingRecord.do",//这个是请求的地址
					"fnServerData" : retrieveData, // 获取数据的处理函数
					"destroy":true,
				      // "bPaginate": true,
				       "bLengthChange": true,      
				      "bSort": false,
				      // "bInfo": true,
				      "bAutoWidth": false,
//				         "bServerSide":true,
				      'aLengthMenu':[5,10, 20], 
				       "searching": false,  
				      /*  "pagingType": "simple_numbers",
				       "dom": "t<'tableinfo'i<'tableSearch'p>l>",  */
				       
				       "language": {//语言设置  
				            "lengthMenu": "每页显示 _MENU_ 条记录",     
				            "zeroRecords": "没有检索到数据",     
				            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
				            "info": "没有数据",     
				            "oPaginate": {     
				                "sFirst": "首页",     
				                "sPrevious": "前一页",     
				                 "sNext": "后一页",     
				                "sLast": "尾页"    
				          	},
				            "search":"",
				            "searchPlaceholder": "请输入关键字",
				            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
				            "infoEmpty":      "没有找到匹配的信息",
				         },  
				         "columnDefs": [{"defaultContent": "",
                             "targets": "_all"}],
                             "columns": [
    				        	 {"data": "id", "className": "hidden-c id-td"},
     		                     {"data": "userid", "className": "hidden-c user-td"},
     		                    {"data": "tikuansxf", "className": "hidden-c tikuansxf-td"},
    		                     { "data": "name",  "className" : "accout-td" },
    		                     { "data": "skname", "className" : "shoukuanhuming-td"},
    		                     { "data": "zhifupt", "className" : "bankType-td"},
    		                     { "data": "caozuo" },
    		                     { "data": "skbankzh", "className" : "bankaccount-td" },
    		                     { "data": "tikuanje", "className": "shenqingjine-td" },
    		                     { "data": "sqtime", "className" : "qukuanTime-td" },
    		                     { "data": "cltime" },
    		                     { "data": "type",   "className" : "tikuanleixing-td" },
    		                     { "data": "state" },
    		                     { "data": "czname" },
    		                     { "data": "beizhu", "className": "beizhu-td" },
    		                 ],
				})

	function retrieveData(sSource, aoData, fnCallback) {
				$.ajax({
					url : sSource,//这个就是请求地址对应sAjaxSource
					data : {
						"pageCount":aoData[0].value,
						"startIndex":aoData[3].value,
						"lineCount":aoData[4].value,
						 "date1" : $('#date1').val(),
		    	        "date2" : $('#date2').val(),
		    	        "type" :$('#tklx').val(),
		    	        "state" : $('#czzt').val(),
		    	        "name" :$('#hymc').val(),
		    	        "daili" : $('#daili').val(),
					},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
					type : 'post',
					dataType : 'json',
					async : false,
					success : function(result) { 
						var newJson = result.aaData
		        		 for (var i = 0; i < newJson.length; i++) {
		         			 var item = newJson[i]
		         			 if (item.caozuo == "锁定") {
		         				 var caozuoHTML = "<button data-type='unlock' class='btn-c-suoding btn btn-primary'>锁定</button>"
		         			 	 var dealShenQingBtn = "<button class='btn-c-dealShenQing btn btn-success'>处理申请</button>"
		         			 	 item.caozuo = caozuoHTML + dealShenQingBtn
		         			 } else if (item.caozuo == "取消锁定") {
		         				var caozuoHTML = "<button data-type='lock' class='btn-c-suoding btn btn-primary'>取消锁定</button>"
		         			 	 var dealShenQingBtn = "<button class='btn-c-dealShenQing btn btn-success active'>处理申请</button>"
		         			 	 item.caozuo = caozuoHTML + dealShenQingBtn			         				 
		         			 }
		        		 }
						result.aaData = newJson;
						fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
						
					},
					error : function(msg) {
					}
				});
			}
			}
		})
		
		$("#button-i-resetTableContent").on("click", function(event) {
			 dataTable01()
			 $('#date1').val("");
	         $('#date2').val("");
	         $('#czzt').val("");
	         $('#tklx').val("");
	         $('#hymc').val("");
	         $('#daili').val("");
		})
		var shouxufei
		bindLockUnlockBtns(".class-tableDataTable","/zhgl/rechageOrDrawingLocking.do")
		$(".class-tableDataTable").on("click", ".btn-c-dealShenQing", function(e) {
			shouxufei=$(this).parent().siblings(".tikuansxf-td").text()
			var $parentTr = $(e.currentTarget).closest("tr")
			$("#myModal .input-auto").each(function(index, element) {
				$(element).text($parentTr.find("." + element.id.split("-")[2] + "-td").text())
			})
			 var TKmoney= $("#input-i-shenqingjine").text()
			var TKname= $("#input-i-shoukuanhuming").text()
			var TKccount= $("#input-i-bankaccount").text()
			var TKbank=$("#input-i-bankType").text()
				TKbank=TKbank.substring(0,TKbank.length-2)
				TKmoney=TKmoney.substring(0,TKmoney.length-2)
				TKname=TKname.substring(0,TKname.length-2)
				TKccount=TKccount.substring(0,TKccount.length-2)
				 $("#input-i-shenqingjine").text(TKmoney)
				  $("#input-i-shoukuanhuming").text(TKname)
				   $("#input-i-bankaccount").text(TKccount) 
				   $("#input-i-bankType").text(TKbank)
			ajax({
				url:"/zhgl/drawingNeed.do",
				type: "post",
				data: {id: $parentTr.find(".user-td").text()},
				success: function(data) {
					var newData = JSON.parse(data)
					for (var k in newData.data) {
						if ($("#ajax-i-" + k).length > 0) {
							$("#ajax-i-" + k).text(newData.data[k])
						}
					}
					var data2Arr = newData.message.split(",")
					$("#qikuanzonge-i").text(data2Arr[1] + "(" + data2Arr[0] + "次)")
					$("#chongzhizonge-i").text(data2Arr[3] + "(" + data2Arr[2] + "次)")
					$("#myModal").attr("data-id", $parentTr.find(".id-td").text())
					$_PARENT_TR = $parentTr
					$("#myModal").modal("show")
					$("#input-i-shouxufei").text(shouxufei)
				},
				error: function(status) {
					showNoticeModal('网络繁忙,请稍候再试')
				}
			})			
		})		 
		$("#btn-i-dealNewTiKuan").on("click", function(e) {
			var $parentTr = $(e.currentTarget).closest("tr")
			var TKmoney= $("#input-i-shenqingjine").text()
			var status = $("#select-i-dealState").val()
			var objItem = {
					url: "/zhgl/drawingAudit.do",
					type: "post",
					data: {
						userid: $_PARENT_TR.find(".user-td").text(),
						id: $_PARENT_TR.find(".id-td").text(), 
						states: status,
						tikuanje: TKmoney,
						tikuansxf:shouxufei,
						state: status == "提款成功" ? "提款成功": "提款失败",
						caozuo: "已处理",
						beizhu: "请注意查收",
						name: $_PARENT_TR.find(".accout-td").text()},
						/* tikuansxf: */
					success: function(data) {
						$_PARENT_TR.find(".shoukuanhuming-td").prev().text("已处理")
						showNoticeModal('操作成功!')
						$("#myModal").modal("hide") 
					 	/*$("#khtkjl").DataTable().ajax.reload()  */
					},
					error: function(status) {
						showNoticeModal('网络繁忙,请稍候再试')
					}
				}
			if (status == "信息有误") {
				var beizhuValue = $("[name='remark']").val()
				if (beizhuValue.trim() == "") {
					showNoticeModal('请填写失败原因')
					return
				}
				objItem.data.beizhu = beizhuValue
			}
			ajax(objItem)				
		})
		$("#select-i-dealState").on("change", function(e) {
			var val = $(e.currentTarget).val()
			if (val == "提款成功") {
				$(".eremark").addClass("hidden")
			} else {
				$(".eremark").removeClass("hidden")
			}
		})
		$("#myModal").on("hidden.bs.modal", function() {
			$("#select-i-dealState").val("提款成功")
			$("[name='remark']").val("")
			$("[name='remark']").addClass("hidden")
		})
		
		$(".tikuan-name").on("click",function(){
			var $o = $("<textarea rows='10' cols='50'>");
			var text=$(this).parent().text();
			text=text.substring(0,text.length-2)
			 $o.val(text)
			 $("#copy-temp").append($o)
			  if (copy($o[0])) {
				  alert("复制成功");  
	            $o.remove()
	        }else{
	            alert("复制失败，请手动复制");
	        }
		})
		
		function copy(obj) {
       		 obj.select();
        try {
            if (document.execCommand('copy', false, null)) {
                document.execCommand("Copy");
                return true;
            } 
        } catch (err) {

        }
        return false;
    }
		
	</script>
